<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('会员列表')" />
</head>
<body class="gray-bg">
    
    <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<div>
							
						</div>
						<ul>
							<li>
								昵称：<input type="text" name="name"/>
							</li>

							<li class="select-time">
								<label>生日： </label>
								<input type="text" class="time-input" placeholder="生日" name="birthDay" />
							</li>

							<li>
								性别：
								<select name="sex" >
									<option value="">全部</option>
									<option value="0">保密</option>
									<option value="1">男</option>
									<option value="2">女</option>
								</select>
							</li>

							<li>
								婚姻状态：
								<select name="wedlock" >
									<option value="">全部</option>
									<option value="0">保密</option>
									<option value="1">未婚</option>
									<option value="2">已婚</option>
								</select>
							</li>

							<li>
								会员等级：
								<select name="memberLvId" >
									<option value="">全部</option>
									<option th:each="entry : ${memberLvNames.entrySet()}" th:text="${entry.getValue()}" th:value="${entry.getKey()}">
									</option>
								</select>
							</li>

							<li>
								注册平台：
								<select name="source">
									<option value="">全部</option>
									<option value="1">pc</option>
									<option value="2">wap</option>
									<option value="3">微信公众号</option>
									<option value="4">微信小程序</option>
									<option value="5">app</option>
								</select>
							</li>

							<li class="select-time">
								<label>注册时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[startTime]" />
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]" />
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="member:member:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="member:member:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="member:member:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="member:member:export">
					<i class="fa fa-download"></i> 导出
				</a>
				<a class="btn btn-default" onclick="showPointModal()" shiro:hasPermission="member:member:export">
					<i class="fa fa-download"></i> 添加积分
				</a>
				<a class="btn btn-primary" onclick="showAdvanceModal()" shiro:hasPermission="member:member:export">
					<i class="fa fa-download"></i> 添加余额
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>

    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('member:member:edit')}]];
        var removeFlag = [[${@permission.hasPermi('member:member:remove')}]];
        var addMemberPointFlag = [[${@permission.hasPermi('member:member:addMemberPoint')}]];
        var addMemberAdvanceFlag = [[${@permission.hasPermi('member:member:addMemberAdvance')}]];
        var prefix = ctx + "member/member";

		var memberLvNames = [[${memberLvNames}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "会员",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'memberId', 
					title : '会员id',
					visible: true
				},
				{
					field : 'name', 
					title : '会员名',
					sortable: true
				},
				{
					field : 'avatar', 
					title : '头像',
					sortable: true,
					formatter: function(val, row, index) {
						if(null == val || val == '') {
							return '-';
						}
						return '<img src="'+ val +'" style="width:30px, height:30px;">';
					}
				},
				{
					field : 'birthDay', 
					title : '生日',
					sortable: true,
					formatter: function(val, row, index) {
						if(null != val && val != '') {
							return val.split(' ')[0];
						}
						return val;
					}
				},
				{
					field : 'sex', 
					title : '性别',
					sortable: true,
					formatter: function(val, row, index) {
						if(val == 0) {
							return '保密';
						} else if(val == 1) {
							return '男';
						} else if(val == 2) {
							return '女';
						}
						return val;
					}
				},
				{
					field : 'wedlock', 
					title : '婚姻状态',
					sortable: true,
					formatter: function(val, row, index) {
						if(val == 0) {
							return '保密';
						} else if(val == 1) {
							return '未婚';
						} else if(val == 2) {
							return '已婚';
						}
						return val;
					}
				},
				{
					field : 'regIp', 
					title : '注册IP',
					sortable: true
				},
				{
					field : 'regTime', 
					title : '注册时间',
					sortable: true
				},
				{
					field : 'memberLvId', 
					title : '会员等级',
					sortable: true,
					formatter: function(val, row, index) {
						return memberLvNames[val];
					}
				},
				{
					field : 'lvExpireTime', 
					title : '等级过期时间',
					sortable: true
				},
				{
					field : 'point', 
					title : '积分',
					sortable: true
				},
				{
					field : 'advance', 
					title : '余额',
					sortable: true
				},
				{
					field : 'education', 
					title : '教育程度',
					sortable: true
				},
				{
					field : 'vocation', 
					title : '职业',
					sortable: true
				},
				{
					field : 'source', 
					title : '注册平台',
					sortable: true,
					formatter: function(val, row, index) {
						if(val == 1) {
							return 'pc';
						} else if(val == 2) {
							return 'wap';
						} else if(val == 3) {
							return '微信公众号';
						} else if(val == 4) {
							return '微信小程序';
						} else if(val == 5) {
							return 'app';
						}
						return val;
					}
				},
				{
					field : 'lastLoginTime', 
					title : '最后登录时间',
					sortable: true
				},
				{
					field : 'lastLoginIp', 
					title : '最后登录ip',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注',
					sortable: true
				},
				{
					field : 'disabled', 
					title : '状态',
					sortable: true,
					formatter: function(value, row, index) {
						if(value == 0) {
							return '有效';
						} else if(value == 1) {
							return '无效';
						} else {
							return value;
						}
					}
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.memberId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.memberId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
		});
		
		/** 显示积分模态框 */
		function showPointModal() {
			$.modal.open('添加会员积分', prefix + '/addPoint');
		}
		
		
		/** 显示余额模态框 */
		function showAdvanceModal() {
			$.modal.open('添加会员余额', prefix + '/addAdvance');
		}
    </script>
</body>
</html>